package com.burstly.lib.util;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build.VERSION;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

@SuppressLint({"NewApi"})
public class ScreenOrientationManager
{
  public static final String LANDSCAPE = "landscape";
  public static final String NONE = "none";
  public static final String PORTRAIT = "portrait";
  private final Reference<Activity> mActivityRef;
  private final int mDefaultOrientation;

  public ScreenOrientationManager(Activity paramActivity)
  {
    this.mActivityRef = new WeakReference(paramActivity);
    this.mDefaultOrientation = paramActivity.getRequestedOrientation();
  }

  private static void changeToLandscape(Activity paramActivity)
  {
    if (isApiHigher9())
    {
      paramActivity.setRequestedOrientation(6);
      return;
    }
    paramActivity.setRequestedOrientation(0);
  }

  private static void changeToPortrait(Activity paramActivity)
  {
    if (isApiHigher9())
    {
      paramActivity.setRequestedOrientation(7);
      return;
    }
    paramActivity.setRequestedOrientation(1);
  }

  private static boolean isApiHigher9()
  {
    return Build.VERSION.SDK_INT >= 9;
  }

  public void restoreDefaultOrientation()
  {
    Activity localActivity = (Activity)this.mActivityRef.get();
    if (localActivity == null)
      return;
    localActivity.setRequestedOrientation(this.mDefaultOrientation);
  }

  public void setOrientation(String paramString, boolean paramBoolean)
  {
    Activity localActivity = (Activity)this.mActivityRef.get();
    if (localActivity == null);
    while (true)
    {
      return;
      if ("portrait".equals(paramString))
        changeToPortrait(localActivity);
      while (paramBoolean)
      {
        localActivity.setRequestedOrientation(-1);
        return;
        if ("landscape".equals(paramString))
          changeToLandscape(localActivity);
        else if (!paramBoolean)
          if (localActivity.getResources().getConfiguration().orientation == 2)
            changeToLandscape(localActivity);
          else
            changeToPortrait(localActivity);
      }
    }
  }

  public void setOrientation(boolean paramBoolean)
  {
    setOrientation("none", paramBoolean);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.util.ScreenOrientationManager
 * JD-Core Version:    0.6.2
 */